<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

	<h3>
		<s:property value="%{getText('Articles and words')}" />
	</h3>

	<s:form method="post" namespace="/services/dictionary2">
		<s:hidden name="articleId" value="%{articleId}"></s:hidden>
		<s:textfield name="sourceLocation" value="%{sourceLocation}"
			key="services.dictionary2.sourceLocation"></s:textfield>
		<s:textfield name="title" value="%{title}"
			key="services.dictionary2.title"></s:textfield>
		<s:textarea name="body" value="%{body}"
			key="services.dictionary2.body" rows="25" cols="160"></s:textarea>
		<s:submit action="index" key="services.dictionary2.find" />
		<s:submit action="index!saveArticle"
			key="services.dictionary2.saveArticle" />

		<s:textfield name="word" value="%{word}"
			key="services.dictionary2.word"></s:textfield>
		<s:textfield name="meaning" value="%{meaning}"
			key="services.dictionary2.meaning"></s:textfield>
		<s:submit action="index!saveMeaning"
			key="services.dictionary2.saveMeaning" />
	</s:form>

	<s:property value="%{pager.totalRecordsCount}" />
	<br />

	<table>
		<s:iterator id="pagerItem" value="%{pager.records}">
			<tr>
				<td><s:url id="gotoUrl" namespace="/services/dictionary2"
						action="index!loadArticle">
						<s:param name="articleId" value="%{#pagerItem.id}"></s:param>
					</s:url> <s:a href="%{gotoUrl}">
						<s:property value="%{title}"></s:property>
					</s:a> / <s:property value="%{#pagerItem.insertionTime}" /><br />

					<div style="margin: 5 5 5 15; font-size: 10px;">
						<s:property value="%{#pagerItem.body}" />
					</div></td>
			</tr>
		</s:iterator>
	</table>

	Words

	<s:if test="%{words != null}">
		<s:form method="post" namespace="/services/dictionary2">
			<s:set var="i" value="0" />
			<s:hidden name="articleId" value="%{articleId}" />
			<table>
				<s:iterator id="wordItem" value="%{words.keys}">
					<s:label
						value="--------------------------------------------------------------------------" />
					<s:label value="%{#wordItem}" />
					<s:hidden name="%{'wordsContexts[' + #i + '].word'}"
						value="%{#wordItem}"></s:hidden>
					<s:if test="%{words[#wordItem] == null}">
						<s:textfield name="%{'wordsContexts[' + #i + '].context'}"
							value="" />
					</s:if>
					<s:else>
						<s:if test="%{words[#wordItem].containsKey(articleId)}">
							<s:textfield name="%{'wordsContexts[' + #i + '].context'}"
								value="%{words[#wordItem][articleId]}" />
						</s:if>
						<s:else>
							<s:textfield name="%{'wordsContexts[' + #i + '].context'}"
								value="" />
						</s:else>
						<s:iterator id="articleItem" value="%{words[#wordItem].keys}">
							<s:if test="%{!articleId.equals(#articleItem)}">
								<s:label value="%{words[#wordItem][#articleItem]}" />
							</s:if>
							<s:else>
							</s:else>
						</s:iterator>
					</s:else>
					<s:set var="i" value="%{ #i + 1 }" />
				</s:iterator>
			</table>
			<s:submit action="index!saveContexts"
				key="services.dictionary2.saveContexts" />
		</s:form>
	</s:if>

</body>
</html>